package userModuleApi

import (
	"KumquatDrivesServices/common/res"
	"KumquatDrivesServices/model"
	redisjwts "KumquatDrivesServices/service/redis_jwts"
	"KumquatDrivesServices/utils"
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
)

func (UserModuleApi) Logout(c *gin.Context) {
	accessToken := c.GetHeader("accessToken")
	refreshToken := c.GetHeader("refreshToken")
	redisjwts.TokenBlack(accessToken, refreshToken)
	userId := utils.GetUserId(c)
	var r model.UserModel
	r.ID = userId
	if err := r.DeleteCacheUser(); err != nil {
		logrus.Errorf("DeleteCacheUser err:%v", err)
	}
	res.OkWithData(map[string]any{}, c)
}
